/*
给定二叉树的根节点 root ，返回所有左叶子之和。

所有的左叶子节点

没有左右子节点的节点就是叶子节点
*/
struct TreeNode {
    int val;
    TreeNode* left;
    TreeNode* right;
    TreeNode() : val(0), left(nullptr), right(nullptr) {}
    TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
    TreeNode(int x, TreeNode* left, TreeNode* right) : val(x), left(left), right(right) {}
};

class Solution {
public:
    bool isLeafNode(TreeNode* node) {
        return node->left == nullptr && node->right == nullptr;
    }

    int sumOfLeftLeaves(TreeNode* root) {
        int res = 0;

        if (root->left != nullptr) {
            if (isLeafNode(root->left)) {
                res += root->left->val;
            } else {
                res += sumOfLeftLeaves(root->left);
            }
        }

        if (root->right != nullptr) {
            if (!isLeafNode(root->right)) {
                res += sumOfLeftLeaves(root->right);
            }
        }

        return res;
    }
};

int main() {
    return 0;
}